package com.lin.blog.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lin.blog.entity.Role;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author lin
 * @since 2020-03-08
 */
public interface RoleMapper extends BaseMapper<Role> {

    /**
     * 通过用户名查询所属的角色
     * @param userName
     * @return
     */
    @Select("select r.* from role r, user u, user_role ur where ur.role_id = r.role_id and u.id = ur.user_id and u.username = #{userName}")
    public List<Role> getRoleByUserName(String userName);

}
